package com.zwb.aiwebsite.controller;


import com.zwb.aiwebsite.common.ResponseResult;
import com.zwb.aiwebsite.entity.TbCarousel;
import com.zwb.aiwebsite.service.TbCarouselService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 轮播图控制器
 * @author 2825075112@qq.com
 */
@Controller
public class CarouselController {

    @Resource
    TbCarouselService tbCarouselService;

    @PostMapping("/carousel")
    @ResponseBody
    public ResponseResult<Void> add(@RequestBody TbCarousel tbCarousel){
        tbCarouselService.add(tbCarousel);
        return ResponseResult.ok();
    }

    @GetMapping("/carousel/all")
    @ResponseBody
    public ResponseResult<List<TbCarousel>> all(){
        List<TbCarousel> all = tbCarouselService.all();
        return ResponseResult.okOf(all);
    }

    @DeleteMapping("/carousel/{id}")
    @ResponseBody
    public ResponseResult<Void> del(@PathVariable Integer id){
        tbCarouselService.del(id);
        return ResponseResult.ok();
    }

}
